package org.jprobe.classpath;

import java.lang.reflect.Constructor;
import java.util.Comparator;
/**
 * constructors comparator
 * @author Hussain Al-Mutawa
 * @version 1.0
 * @since 1.0
 */
public class ConstructorsComparator implements Comparator<Constructor<?>>{
	/** this is the only copy created for this object on the application level **/
	private transient final static ConstructorsComparator INSTANCE = new ConstructorsComparator();
	/** this class can not be initialized **/
	private ConstructorsComparator(){super();}
	/**
	 * gets a singleton instance of the comparator
	 * @return instance of the class
	 */
	public static ConstructorsComparator instance(){
		return INSTANCE;
	}
	@Override
	public int compare(final Constructor<?> const1, final Constructor<?> const2) {
		return const1.getParameterTypes().length-const2.getParameterTypes().length<0?-1:const1.toString().compareTo(const2.toString());
	}
}
